﻿using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using UniMana.Data;
using UniMana.Utils.Data;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraEditors;
using UniMana.Utils.Configs;

namespace UniMana.Win.Training
{
    public partial class FrmStudent_SubAcademicHandlingTransferCourseDetail : DevExpress.XtraEditors.XtraForm
    {
        int m_iLog_TranferKey = 0;
        private Log_TranferInfo tranferinfo;
        private DBMain m_data = new DBMain();

        public FrmStudent_SubAcademicHandlingTransferCourseDetail(int m_iLog_TranferKey)
        {
            InitializeComponent();
            SysUtils.SetRuleControl(this.Controls, this.Name);
            this.m_iLog_TranferKey = m_iLog_TranferKey;
        }

        private void Frm_AcademicHandling_Transfer_Course_Detail_Load(object sender, EventArgs e)
        {
            this.Width = 518;
            this.Height = 330;
            LoadData();
            tranferinfo = new Log_TranferInfo(m_iLog_TranferKey);

            lueTraining_Student.EditValue = tranferinfo.Properties.Training_StudentKey;
            lueTraining_TrainingProgram1.EditValue = tranferinfo.Properties.Training_TrainingProgramKeyBefore;
            lueTraining_TrainingProgram2.EditValue = tranferinfo.Properties.Training_TrainingProgramKeyAfter;
            lueTraining_Class1.EditValue = tranferinfo.Properties.ClassBefore;
            lueTraining_Class2.EditValue = tranferinfo.Properties.ClassAfter;
            txtID1.Text = tranferinfo.Properties.BeforeID;
            txtID2.Text = tranferinfo.Properties.AfterID;
            rtbReasons.Text = tranferinfo.Properties.Reasons;
            DateTime datetime = new DateTime();
            datetime = Convert.ToDateTime(tranferinfo.Properties.TranferTime);
            txtDatetime1.Text = datetime.Day + "/" + datetime.Month + "/" + datetime.Year + " - " + datetime.Hour + ":" + datetime.Minute + ":" + datetime.Second;
            if (tranferinfo.Properties.Status == true)
            {
                if (tranferinfo.Properties.Permit == true)
                    txtStatus.Text = "Đã duyệt";
                else
                    txtStatus.Text = "Không duyệt";
                datetime = new DateTime();
                datetime = Convert.ToDateTime(tranferinfo.Properties.CensorshipTime);
                txtDatetime2.Text = datetime.Day + "/" + datetime.Month + "/" + datetime.Year + " - " + datetime.Hour + ":" + datetime.Minute + ":" + datetime.Second;
                try
                {
                    rtbFeedback.Text = tranferinfo.Properties.Feedback.ToString();
                }
                catch { rtbFeedback.Text = ""; }
                this.Width = 518;
                this.Height = 363;
                lbcDatetime2.Visible = true;
                lbcFeedback.Visible = true;
                txtDatetime2.Visible = true;
                rtbFeedback.Visible = true;
            }
            else
            {
                txtStatus.Text = "Chờ duyệt";
            }
        }

        private void LoadData()
        {
            lueTraining_Student.GetData(m_data.m_DCReadOnly.Training_Students.GetData(), "Training_StudentKey", "Name");
            lueTraining_TrainingProgram1.GetData(m_data.m_DCReadOnly.Training_TrainingPrograms, "Training_TrainingProgramKey", "Name");
            lueTraining_TrainingProgram2.GetData(m_data.m_DCReadOnly.Training_TrainingPrograms, "Training_TrainingProgramKey", "Name");
            lueTraining_Class1.GetData(m_data.m_DCReadOnly.Training_Classes, "Training_ClassKey", "Name");
            lueTraining_Class2.GetData(m_data.m_DCReadOnly.Training_Classes, "Training_ClassKey", "Name");
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
